예제 #1
0
파일: start.php 프로젝트: elgg/apiadmin
/**
 * Event handler for when an API key is deleted
 * 
 * @param unknown_type $event
 * @param unknown_type $object_type
 * @param unknown_type $object
 */
function apiadmin_delete_key($event, $object_type, $object = null)
{
    global $CONFIG;
    if ($object && $object->subtype === get_subtype_id('object', 'api_key')) {
        // Delete secret key
        return remove_api_user($CONFIG->site_id, $object->public);
    }
    return true;
}
예제 #2
0
 * Elgg API Admin
 * Implementation of the Regenerate Keys option on an API Key object
 * 
 * @package ElggAPIAdmin
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * 
 * @author Moodsdesign Ltd
 * @copyright Moodsdesign Ltd 2012
 * @link http://www.elgg.org
*/
global $CONFIG;
admin_gatekeeper();
$key = (int) get_input('keyid');
$obj = get_entity($key);
if ($obj && $obj instanceof ElggObject && $obj->subtype == get_subtype_id('object', 'api_key')) {
    if (remove_api_user($CONFIG->site_id, $obj->public)) {
        $keypair = create_api_user($CONFIG->site_id);
        if ($keypair) {
            $obj->public = $keypair->api_key;
        } else {
            register_error(elgg_echo('apiadmin:regenerationfail'));
        }
        if (!$obj->save()) {
            register_error(elgg_echo('apiadmin:regenerationfail'));
        } else {
            system_message(elgg_echo('apiadmin:regenerated'));
        }
    } else {
        register_error(elgg_echo('apiadmin:regenerationfail'));
    }
}
예제 #3
0
 /**
  * Also remove API user when deleting the object
  * 
  * @param boolean $recursive if the delete should be recursive
  * 
  * @return boolean
  * 
  * @see ElggEntity::delete()
  */
 function delete($recursive = true)
 {
     if ($keys = $this->getApiKeys()) {
         remove_api_user($this->site_guid, $keys["api_key"]);
     }
     return parent::delete($recursive);
 }
예제 #4
0
 /**
  * Also remove API user when deleting the object
  *
  * @param boolean $recursive if the delete should be recursive
  *
  * @return bool
  *
  * @see ElggEntity::delete()
  */
 public function delete($recursive = true)
 {
     $keys = $this->getApiKeys();
     if (!empty($keys)) {
         remove_api_user($this->site_guid, $keys['api_key']);
     }
     return parent::delete($recursive);
 }