diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/RedDAV/RedDirectory.php | 21 | ||||
-rw-r--r-- | include/acl_selectors.php | 2 | ||||
-rw-r--r-- | include/api.php | 90 | ||||
-rw-r--r-- | include/text.php | 10 |
4 files changed, 119 insertions, 4 deletions
diff --git a/include/RedDAV/RedDirectory.php b/include/RedDAV/RedDirectory.php index 87bdf8f13..8d8af5bd3 100644 --- a/include/RedDAV/RedDirectory.php +++ b/include/RedDAV/RedDirectory.php @@ -363,6 +363,27 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota { } /** + * @brief delete directory + */ + + public function delete() { + logger('delete file ' . basename($this->red_path), LOGGER_DEBUG); + + if ((! $this->auth->owner_id) || (! perm_is_allowed($this->auth->owner_id, $this->auth->observer, 'write_storage'))) { + throw new DAV\Exception\Forbidden('Permission denied.'); + } + + if ($this->auth->owner_id !== $this->auth->channel_id) { + if (($this->auth->observer !== $this->data['creator']) || intval($this->data['is_dir'])) { + throw new DAV\Exception\Forbidden('Permission denied.'); + } + } + + attach_delete($this->auth->owner_id, $this->folder_hash); + } + + + /** * @brief Checks if a child exists. * * @param string $name diff --git a/include/acl_selectors.php b/include/acl_selectors.php index cb2266473..4d44ec12e 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -231,6 +231,7 @@ function populate_acl($defaults = null,$show_jotnets = true) { $jotnets = ''; if($show_jotnets) { +logger('jot_networks'); call_hooks('jot_networks', $jotnets); } @@ -243,6 +244,7 @@ function populate_acl($defaults = null,$show_jotnets = true) { '$allowgid' => json_encode($allow_gid), '$denycid' => json_encode($deny_cid), '$denygid' => json_encode($deny_gid), + '$jnetModalTitle' => t('Other networks and post services'), '$jotnets' => $jotnets, '$aclModalTitle' => t('Permissions'), '$aclModalDismiss' => t('Close') diff --git a/include/api.php b/include/api.php index b51bcc5f0..875bf121f 100644 --- a/include/api.php +++ b/include/api.php @@ -2416,6 +2416,96 @@ logger('Req: ' . var_export($req,true)); api_register_func('api/oauth/request_token', 'api_oauth_request_token', false); api_register_func('api/oauth/access_token', 'api_oauth_access_token', false); + + +function api_export_users(&$a,$type) { + + if (! is_site_admin()){ + header('HTTP/1.0 401 Unauthorized'); + die('Only admin accounts may use this endpoint.'); + } + + $r = q("SELECT * FROM account"); + + // TODO: paginating! + + $ret = array(); + foreach($r as $u){ + $ret[] = $u; + } + + json_return_and_die(array('status' => 'OK', + 'users' => $u)); +} +api_register_func('api/export/users','api_export_users', true); + + + +function api_export_channel_hashes(&$a, $type) { + + if (! is_site_admin()){ + header('HTTP/1.0 401 Unauthorized'); + die('Only admin accounts may use this endpoint.'); + } + + if( $_REQUEST['account_id'] == ''){ + header('HTTP/1.0 422 Unprocessable Entity'); + die('Must supply account_id parameter.'); + + } + + $c = q("select * from channel where channel_account_id = '%d'", + intval($_REQUEST['account_id'])); + + if(! $c){ + header('HTTP/1.0 404 Not Found'); + die('No such account_id '. $_REQUEST['account_id']); + + } + + $ret = array(); + foreach ($c as $r){ + $ret[] = $r['channel_hash']; + } + json_return_and_die(array('status' => 'OK', + 'channel_hashes' => $ret)); +} +api_register_func('api/export/channels','api_export_channel_hashes', true); + + + + +function api_export_identity(&$a, $type) { + + if (! is_site_admin()){ + header('HTTP/1.0 401 Unauthorized'); + die('Only admin accounts may use this endpoint.'); + } + + if( $_REQUEST['channel_hash'] == ''){ + header('HTTP/1.0 422 Unprocessable Entity'); + die('Must supply channel_hash parameter.'); + + } + + require_once('include/identity.php'); + + $c = q("select channel_id from channel where channel_hash = '%s' LIMIT 1", + dbesc($_REQUEST['channel_hash'])); + + if(! $c){ + header('HTTP/1.0 404 Not Found'); + die('No such channel '. $_REQUEST['channel_hash']); + + } + json_return_and_die( + identity_basic_export($c[0]['channel_id'], + (($_REQUEST['posts']) ? intval($_REQUEST['posts']) : 0 ))); +} +api_register_func('api/export/identity','api_export_identity', true); + + + /* Not implemented by now: statuses/retweets_of_me diff --git a/include/text.php b/include/text.php index c2573da0c..edaa8dcd3 100644 --- a/include/text.php +++ b/include/text.php @@ -872,15 +872,17 @@ function searchbox($s,$id='search-box',$url='/search',$save = false) { )); } +function valid_email_regex($x){ + if(preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x)) + return true; + return false; +} function valid_email($x){ if(get_config('system','disable_email_validation')) return true; - if(preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x)) - return true; - - return false; + return valid_email_regex($x); } /** |